Make the default default colormap the GdkRGB colormap, not the system
authorOwen Taylor <otaylor@redhat.com>
Fri, 7 Sep 2001 23:11:17 +0000 (23:11 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 7 Sep 2001 23:11:17 +0000 (23:11 +0000)
Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkwidget.c (gtk_widget_get_default_colormap):
Make the default default colormap the GdkRGB colormap,
not the system colormap.

* gtk/gtkinvisible.c (gtk_invisible_init)
  gtk/gtkwindow.c (gtk_window_init): Set the current
colormap, as returned by _gtk_widget_peek_colormap()
on the widget.

* gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
to GTK+. Make it return %NULL instead of the default
colormap if no colormap has explicitely been pushed.

* gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
colormaps on ancestral widgets before defaulting the
the system default colormap.

* docs/Changes-2.0.txt: explain colormap changes.

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/Changes-2.0.txt
gtk/gtkinvisible.c
gtk/gtkwidget.c
gtk/gtkwidget.h
gtk/gtkwindow.c

index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index d3e1d193102e523dd7180831c79dd25c21e33386..d1d8d35a1d97b69ef4c717ff00506efff8bb38f7 100644 (file)
@@ -1,3 +1,24 @@
+Fri Sep  7 18:50:59 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwidget.c (gtk_widget_get_default_colormap): 
+       Make the default default colormap the GdkRGB colormap,
+       not the system colormap.
+
+       * gtk/gtkinvisible.c (gtk_invisible_init) 
+         gtk/gtkwindow.c (gtk_window_init): Set the current
+       colormap, as returned by _gtk_widget_peek_colormap()
+       on the widget.
+
+       * gtk/gtkwidget.[ch]: Export _gtk_widget_peek_colormap
+       to GTK+. Make it return %NULL instead of the default
+       colormap if no colormap has explicitely been pushed.
+
+       * gtk/gtkwidget.c (gtk_widget_get_colormap): Check for
+       colormaps on ancestral widgets before defaulting the
+       the system default colormap.
+
+       * docs/Changes-2.0.txt: explain colormap changes.
+
 2001-09-07  Havoc Pennington  <hp@redhat.com>
 
        * gtk/gtktextiter.c: add some lame code to handle G_MININT, fixes 
index e4260eabf034c1a300b3be451534f28d85f18f78..a44f5aedabaa8a2391bdb59b6fc336380b9b8169 100644 (file)
@@ -477,7 +477,21 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
    gdk_wm_take_focus                      gdk_atom_intern ("WM_TAKE_FOCUS", FALSE)
    gdk_wm_protocols                       gdk_atom_intern ("WM_PROTOCOLS", FALSE)
    
-   
+* The handling of Colormaps and widgets has been changed:
+
+    - The default colormap for widgets is now the GdkRGB colormap, not
+      the system default colormap. If you try to use resources created for  
+      a widget (e.g., widget->style) with a window using the system
+      colormap, errors will result on some machines.
+
+    - gtk_widget_push/pop_colormap() only cause the colormap to be
+      explicitely set on toplevel widgets not on all widgets. The
+      colormap for other widgets (when not set using 
+      gtk_widget_set_colormap()), is determined by finding the nearest
+      ancestor with a colormap set on it explicitely, or if that
+      fails, the default colormap.
 
   
+      
 
+      
\ No newline at end of file
index fc19d330660baa8cd6dc12264863a2b84a97d448..529b3b3688e9a7ee11c670c7d278284276545e10 100644 (file)
@@ -83,6 +83,8 @@ gtk_invisible_class_init (GtkInvisibleClass *class)
 static void
 gtk_invisible_init (GtkInvisible *invisible)
 {
+  GdkColormap *colormap;
+  
   GTK_WIDGET_UNSET_FLAGS (invisible, GTK_NO_WINDOW);
   GTK_WIDGET_SET_FLAGS (invisible, GTK_TOPLEVEL);
 
@@ -90,6 +92,10 @@ gtk_invisible_init (GtkInvisible *invisible)
   gtk_object_sink (GTK_OBJECT (invisible));
 
   invisible->has_user_ref_count = TRUE;
+  
+  colormap = _gtk_widget_peek_colormap ();
+  if (colormap)
+    gtk_widget_set_colormap (GTK_WIDGET (invisible), colormap);
 }
 
 static void
index f5bcfcad98dcea34933d960d07e8d072f21214ac..2d731a7ccf9004add307c94160ef7d3bf2f285f0 100644 (file)
@@ -194,7 +194,6 @@ static gboolean             gtk_widget_real_focus_out_event         (GtkWidget        *widget,
                                                                 GdkEventFocus    *event);
 static gboolean                gtk_widget_real_focus                   (GtkWidget        *widget,
                                                                 GtkDirectionType  direction);
-static GdkColormap*    gtk_widget_peek_colormap                (void);
 static PangoContext*   gtk_widget_peek_pango_context           (GtkWidget        *widget);
 static void            gtk_widget_reparent_container_child     (GtkWidget        *widget,
                                                                 gpointer          client_data);
@@ -1253,11 +1252,6 @@ gtk_widget_init (GtkWidget *widget)
 
   widget->style = gtk_widget_get_default_style ();
   gtk_style_ref (widget->style);
-  
-  colormap = gtk_widget_peek_colormap ();
-  
-  if (colormap != gtk_widget_get_default_colormap ())
-    gtk_widget_set_colormap (widget, colormap);
 }
 
 
@@ -4695,10 +4689,15 @@ gtk_widget_get_colormap (GtkWidget *widget)
       if (colormap)
        return colormap;
     }
-  
-  colormap = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_colormap);
-  if (colormap)
-    return colormap;
+
+  while (widget)
+    {
+      colormap = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_colormap);
+      if (colormap)
+       return colormap;
+
+      widget = widget->parent;
+    }
 
   return gtk_widget_get_default_colormap ();
 }
@@ -4944,14 +4943,8 @@ gtk_widget_push_colormap (GdkColormap *cmap)
 void
 gtk_widget_pop_colormap (void)
 {
-  GSList *tmp;
-  
   if (colormap_stack)
-    {
-      tmp = colormap_stack;
-      colormap_stack = colormap_stack->next;
-      g_slist_free_1 (tmp);
-    }
+    colormap_stack = g_slist_delete_link (colormap_stack, colormap_stack);
 }
 
 /**
@@ -4987,7 +4980,7 @@ GdkColormap*
 gtk_widget_get_default_colormap (void)
 {
   if (!default_colormap)
-    gtk_widget_set_default_colormap (gdk_colormap_get_system ());
+    gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
   
   return default_colormap;
 }
@@ -5346,20 +5339,18 @@ gtk_widget_real_size_request (GtkWidget         *widget,
   requisition->height = widget->requisition.height;
 }
 
-/*****************************************
- * gtk_widget_peek_colormap:
- *
- *   arguments:
- *
- *   results:
- *****************************************/
-
-static GdkColormap*
-gtk_widget_peek_colormap (void)
+/**
+ * _gtk_widget_peek_colormap:
+ * 
+ * Returns colormap currently pushed by gtk_widget_push_colormap, if any.
+ * 
+ * Return value: the currently pushed colormap, or %NULL if there is none.
+ **/
+GdkColormap*
+_gtk_widget_peek_colormap (void)
 {
   if (colormap_stack)
     return (GdkColormap*) colormap_stack->data;
-  return gtk_widget_get_default_colormap ();
 }
 
 static void
index edcd1d89f4a60bb7b79c8d6920af76addc923505..068cac33fb6a4028b2a7bbd777aaa6e8752b5ce1 100644 (file)
@@ -757,6 +757,8 @@ GtkWidgetAuxInfo *_gtk_widget_get_aux_info                (GtkWidget    *widget,
 void              _gtk_widget_propagate_hierarchy_changed (GtkWidget    *widget,
                                                           GtkWidget    *previous_toplevel);
 
+GdkColormap* _gtk_widget_peek_colormap (void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index e0d8ab6bd7d077b471a78c3e81bf0616a4176617..86ba6c46a9e743734cad62b6f7cc1a62b37c178a 100644 (file)
@@ -576,6 +576,8 @@ gtk_window_class_init (GtkWindowClass *klass)
 static void
 gtk_window_init (GtkWindow *window)
 {
+  GdkColormap *colormap;
+  
   GTK_WIDGET_UNSET_FLAGS (window, GTK_NO_WINDOW);
   GTK_WIDGET_SET_FLAGS (window, GTK_TOPLEVEL);
 
@@ -610,6 +612,10 @@ gtk_window_init (GtkWindow *window)
   window->decorated = TRUE;
   window->mnemonic_modifier = GDK_MOD1_MASK;
   
+  colormap = _gtk_widget_peek_colormap ();
+  if (colormap)
+    gtk_widget_set_colormap (GTK_WIDGET (window), colormap);
+  
   gtk_widget_ref (GTK_WIDGET (window));
   gtk_object_sink (GTK_OBJECT (window));
   window->has_user_ref_count = TRUE;